/******************* 公共变量 *******************/
var userId = core.getUrlData('user_id'),
	isSelf = core.getUrlData('is_self'),
	registerUserId = core.getUrlData('bm_user_id'),
	register = core.getUrlData('register'),
	is_askfor = core.getUrlData('is_askfor'),
	ask_status = core.getUrlData('ask_status'),
	activityId = core.getUrlData('activity_id'),
	footerFrom = core.getUrlData('from'),
	firstRecord = true,
	$showTime,
	citySelect = false,
	addImg = '',
	record = {
		localId: '',
		serverId: '',
		localIds: '',
	},
	stopRecord,
	startRecord,
	saveRecord,
	pausePlay,
	stopPlay,
	startPlay,
	selfStartPlay;

/******************* 底部导航栏显示 *******************/
footerFrom && $('html body .index-footer a').eq(footerFrom).addClass('active');

wx.ready(function () {
	wx.checkJsApi({  
		jsApiList : ['uploadImage','previewImage','chooseImage','scanQRCode','startRecord','stopRecord','onVoiceRecordEnd','playVoice','onVoicePlayEnd','onMenuShareAppMessage'],  
		success : function(res) {  
		}
	});

	// 录音时间超过一分钟没有停止的时候会执行 complete 回调
	wx.onVoiceRecordEnd({
		complete: function (res) {
			record.localId = res.localId;
			$showTime.html('录音上传中...');
			wx.uploadVoice({
				localId: record.localId,
				isShowProgressTips: 1,
				success: function (res) {
					// alert(res.serverId)
					record.serverId = res.serverId;
					(vm.is_self == 1) && (vm.voice_id = record.serverId);
					$.getJSON(sendVoiceUrl,{media_id:record.serverId}, function(data) {
						if(data) {
							core.layerHint('录音上传成功，审核通过后其他人可听');
							vm.voice_id = data.media_id;
							// alert("Send successfully");
						}
					});
				}
			});
			// $("#record").html('开始录音');
		}
	});

	// 监听语音播放完毕接口
	wx.onVoicePlayEnd({
		success: function (res) {
			record.localId = res.localId; // 返回音频的本地ID
			vm.isPlay = false;
			clearInterval(vm.playTimer);
			vm.playColor = 0;
			// alert('播放完毕');
		}
	});

	startRecord = function () {
		wx.startRecord();
	}

	$showTime && $showTime.html('按住说话');

	stopRecord = function () {
		wx.stopRecord({
			success: function (res) {
				record.localId = res.localId;
			}
		});
	}

	saveRecord = function () {
		wx.uploadVoice({
			localId: record.localId,
			isShowProgressTips: 1,
			success: function (res) {
				// alert(res.serverId)
				record.serverId = res.serverId;
				(vm.is_self == 1) && (vm.voice_id = record.serverId);
				$.getJSON(sendVoiceUrl,{media_id:record.serverId}, function(data) {
					if(data) {
						core.layerHint('录音上传成功，审核通过后其他人可听');
						vm.voice_id = data.media_id;
						// alert("Send successfully");
					}
				});
			}
		});
	}

	pausePlay = function () {
		wx.pauseVoice({
			localId: record.localId // 需要暂停的音频的本地ID，由stopRecord接口获得
		});
	}

	stopPlay = function () {
		wx.stopVoice({
			localId: record.localId // 需要停止的音频的本地ID，由stopRecord接口获得
		});
	}

	startPlay = function () {
		wx.downloadVoice({
			serverId: vm.voice_id,
			isShowProgressTips: 1,
			success: function (res) {
				// alert(res.localId);
				record.localId = res.localId;
				// alert(record.localId);
				//播放录音
				wx.playVoice({
					localId: record.localId
				});
			}
		});
	}

	selfStartPlay = function () {
		//播放录音
		wx.playVoice({
			localId: record.localId
		});
	}
});

/******************* 个人信息载入 *******************/
function getData() {
	// 资料
	$.ajax({
		url: userDetailUrl,
		type: 'post',
		data: {user_id: userId},
		success: function (data) {
			console.log(data)

			if (data.status == 0) {
				core.layerHint(data.message);
			} else {
				$('title').html(data.list.username);
			}
			$.extend(vm, data.list);
			
			vm.label = core.delEmptyArr(data.list.label);
		}
	});
	// 相册
	$.ajax({
		url: photoUrl,
		type: 'post',
		data: {user_id: userId},
		success: function (data) {
			console.log(data)

			if (data.status == 0) {
				core.layerHint(data.message);
			}
			vm.images = data.list;
		}
	});
}

/******************* Vue初始化代码 *******************/
var vm = new Vue({
	el: 'body .wrap',
	data: {
		is_self: isSelf,
		user_id: userId,
		user_name: userNameUrl,
		user_age: userAgeUrl,
		user_intro: userIntroUrl,
		user_city: userCityUrl,
		user_job: userJobUrl,
		user_body: userBodyUrl,
		user_label: userLabelUrl,
		user_album: userAlbumUrl,
		user_contact: userContactUrl,
		photo_id: '',
		id: '',
		username: '',
		age: '',
		sex: '',
		voice_id: '',
		is_verify: '',
		is_friend: '',
		introduction: '',
		city: '',
		job: '',
		body_shape: '',
		label: [],
		labelStr: '',
		images: [],
		times: '',
		timekeeping: '',
		open: '',
		chat: '',
		late: '',
		pride: '',
		communication: '',
		updateImage: addImg,
		activity: [
			
		],
		good: [],
		bad: [],
		meetingPage: meetingPage,
		is_black: 0,
		cate: '',
		detail: '',
		drink: '',
		gift: '',
		id: '',
		is_mate: '',
		is_remove: '',
		join_ed: '',
		join_money: '',
		people: '',
		position: '',
		right: '',
		site: '',
		start_time: '',
		status: '',
		theme: '',
		type: '',
		sex: '',
		star: '',
		longitude: '',
		latitude: '',
		bm_user_id: registerUserId,
		activity_id: activityId,
		register: register,
		askClass: '',
		isAsk: '',
		is_askfor: is_askfor,
		ask_status: ask_status,
		isDateTimeClose: false,
		isPlay: false,
		playTimer: 0,
		playColor: 0,
		isRecord: false,
		recordTimer: 0,
		recordTime: 0,
		recordColor: 0,
		auditionTimer: 0,
		auditionTime: 0,
		iOS: $.os.ios
	},
	methods: {
		showHeader: function () {
			var _this = this;
			common.layerConfirm({
				content: '<img alt="" title="" src="' + _this.photo_id + '">',
				btn: false,
				success: function () {
					$('body .layui-m-layer .layui-m-layermain .layui-m-layersection .layui-m-anim-scale .layui-m-layercont').css({
						padding: '0.4rem',
						'-webkit-box-shadow': 'none',
						'-moz-box-shadow': 'none',
						'-ms-box-shadow': 'none',
						'-o-box-shadow': 'none',
						'box-shadow': 'none'
					});
					$('body .layui-m-layer .layui-m-layermain .layui-m-layersection .layui-m-anim-scale .layui-m-layercont img').css({
						width: '23.2rem',
						height: '23.2rem',
						'-webkit-border-radius': '0.6rem',
						'-moz-border-radius': '0.6rem',
						'-ms-border-radius': '0.6rem',
						'-o-border-radius': '0.6rem',
						'border-radius': '0.6rem'
					});
				}
			});
		},
		href: function (href, str) {
			if (this.is_self == 1) {
				core.href(href + '?user_id=' + this.user_id + str);
			}
		},
		focus: function (event) {
			var _this = this;
			$.ajax({
				url: myInfoUrl,
				type: 'post',
				success: function (data) {
					console.log(data);
					if (data.list.is_verify == 1) {
						if (_this.is_friend == 0) {
							$.ajax({
								url: focusUrl,
								type: 'post',
								data: {fo_user_id: userId},
								success: function (data) {
									console.log(data)

									if (data.result == 0) {
										core.layerHint(data.message);
									} else if (data.result == 1) {
										_this.is_friend = 1;
									}
								}
							});
						} else {
							$.ajax({
								url: noFocusUrl,
								type: 'post',
								data: {fo_user_id: userId},
								success: function (data) {
									console.log(data)

									if (data.result == 0) {
										core.layerHint(data.message);
									} else if (data.result == 1) {
										_this.is_friend = 0;
									}
								}
							});
						}
					} else {
						if (data.list.jump_status == 4) {
							core.href(userIdentifyUrl + '?user_id=' + data.list.id);
						} else if (data.list.jump_status == 5) {
							core.href(userHeaderUrl + '?user_id=' + data.list.id);
						} else {
							core.href(userCompleteUrl);
						}
					}
				}
			});
		},
		refuse: function () {
			var _this = this;
			common.layerConfirm({
				content: ((_this.ask_status == 2) ? '确认拒绝' + _this.username + '的查看头像请求吗？' : '确认拒绝' + _this.username + '的关注请求吗？拒绝后TA将不可报名本次活动。'),
				yesClose: false,
				yes: function () {
					$.ajax({
						url: ((_this.ask_status == 2) ? notPhotoUrl : notFollowUrl),
						type: 'post',
						data: {
							user_id: _this.user_id,
							id: _this.activity_id
						},
						success: function(data) {
							console.log(data)

							core.layerHint(data.message);
							if (data.status == 1) {
								_this.isAsk = 2;
							}
						}
					});
				}
			});
		},
		accept: function () {
			var _this = this;
			$.ajax({
				url: ((_this.ask_status == 2) ? yesPhotoUrl : yesFollowUrl),
				type: 'post',
				data: {
					user_id: _this.user_id,
					id: _this.activity_id
				},
				success: function(data) {
					console.log(data)

					core.layerHint(data.message);
					if (data.status == 1) {
						_this.isAsk = 1;
					}
				}
			});
		},
		selectDate: function () {
			if (this.is_self == 1) {
				
			}
		},
		updateImg: function (event) {
			var _this = this;

			lrz(document.getElementById('updateImage').files[0], {
				width: 500,
				quality: 0.8
			}).then(function(data) {
				$.ajax({
					url: userAddPhotoUrl,
					type: 'post',
					data: {
						user_id: userId,
						image: data.base64
					},
					success: function(data) {
						console.log(data)

						core.layerHint(data.message);
						if (data.result == 1) {
							getData();
						}
					}
				});
			});
		},
		record: function () {
			var _this = this;
			layer.open({
				content: '<p>你可以说“下一场想要夜生活玩伴，那就一起来吧~”</p><span></span><strong>按住说话</strong>',
				btn: ['保存', '取消'],
				skin: 'footer',
				className: 'user-record',
				success: function (ele) {
					firstRecord && (wx && wx.startRecord());
					var $ele = $(ele),
						$btnBox = $('body .layui-m-layer .layui-m-layermain .layui-m-layersection .user-record .layui-m-layerbtn'),
						$record = $('body .layui-m-layer .layui-m-layermain .layui-m-layersection .user-record .layui-m-layercont span'),
						$description = $('body .layui-m-layer .layui-m-layermain .layui-m-layersection .user-record .layui-m-layercont p'),
						recordType = 0;
					$showTime = $('body .layui-m-layer .layui-m-layermain .layui-m-layersection .user-record .layui-m-layercont strong');

					$record.on('touchstart', function (event) {
						event.preventDefault();
						if (firstRecord) {
							wx && wx.stopRecord();
							firstRecord = false;
						}
						setTimeout(function () {
							if (recordType == 0) {
								if (startRecord) {
									$showTime.html('0s');
									startRecord();
								} else {
									$showTime.html('录音准备中，请稍候');
								}
								_this.recordTimer = setInterval(function () {
									_this.recordTime += 100;
									if ((_this.recordTime % 1000) == 0) {
										$showTime.html((_this.recordTime / 1000) + 's');
									}
									if (_this.recordTime >= 10000) {
										recordStop();
									}
								}, 100);
							}
						}, 300);
					}).on('touchend', function () {
						if (recordType == 0) {
							recordStop();
						}
					});

					function recordStop() {
						clearInterval(_this.recordTimer);
						stopRecord && stopRecord();
						// _this.recordTime = 0;
						_this.auditionTime = _this.recordTime;
						$description.html(core.decimalRound(_this.recordTime / 1000, 0) + 's');
						$record.addClass('play');
						$showTime.css(dn);
						$btnBox.addClass('show-btn');
						recordType = 1;
						setTimeout(function () {
							$record.on('tap', function () {
								if (recordType == 1) {
									selfStartPlay && selfStartPlay();
									recordType = 2;
									$description.html(core.decimalRound(_this.recordTime / 1000, 0) + 's');
									$record.removeClass('play').addClass('pause');
									_this.auditionTimer = setInterval(function () {
										_this.recordTime -= 100;
										if ((_this.recordTime % 1000) == 0) {
											$description.html((_this.recordTime / 1000) + 's');
										}
										if (_this.recordTime <= 0) {
											auditionStop();
											_this.recordTime = _this.auditionTime;
											$description.html(core.decimalRound(_this.recordTime / 1000, 0) + 's');
										}
									}, 100)
								} else if (recordType == 2) {
									auditionStop();
								}
							});
						}, 25);
					}

					function auditionStop() {
						pausePlay && pausePlay();
						clearInterval(_this.auditionTimer);
						recordType = 1;
						// _this.recordTime = _this.auditionTime;
						// $description.html(core.decimalRound(_this.recordTime / 1000, 0) + 's');
						$record.removeClass('pause').addClass('play');
					}
				},
				yes: function (index) {
					saveRecord && saveRecord();
				},
				no: function (index) {
					layer.close(index);
				},
				end: function () {
					clearInterval(_this.recordTimer);
					_this.auditionTime = 0;
					_this.recordTime = 0;
					if (firstRecord) {
						wx && wx.stopRecord();
						firstRecord = false;
					}
				}
			});
			// if (this.isRecord) {
			// 	this.isRecord = false;
			// 	stopRecord();
			// 	clearInterval(this.recordTimer);
			// 	this.recordColor = 0;
			// 	layer.closeAll();
			// } else {
			// 	if (startRecord) {
			// 		this.isRecord = true;
			// 		startRecord();
			// 		layer.open({
			// 			content: '问候语录制中...',
			// 			skin: 'msg'
			// 		});
			// 		this.recordTimer = setInterval(function () {
			// 			_this.recordColor ? (_this.recordColor = 0) : (_this.recordColor = 1);
			// 		}, 500);
			// 	} else {
			// 		core.layerHint('录音准备中，请稍候');
			// 	}
			// }
		},
		play: function () {
			var $audio = $('audio'),
				audio = $audio[0],
				_this = this;
			if (this.isPlay) {
				audio.pause();
				audio.load();
				// stopPlay();
				this.isPlay = false;
				// clearInterval(this.playTimer);
				this.playColor = 0;
			} else {
				audio.play();
				this.isPlay = true;
				_this.playColor = 1;
				// this.playTimer = setInterval(function () {
				// 	_this.playColor ? (_this.playColor = 0) : (_this.playColor = 1);
				// }, 500);
				
				// if (startPlay) {
				// 	if (_this.voice_id) {
				// 		startPlay();
				// 		this.isPlay = true;
				// 	} else {
				// 		(_this.is_self == 1) ? core.layerHint('您还未上传问候语') : core.layerHint('用户还未上传问候语');
				// 	}
				// } else {
				// 	core.layerHint('播放准备中，请稍候');
				// }
			}
		},
		stopPlay: function () {
			this.isPlay = false;
			// clearInterval(this.playTimer);
			this.playColor = 0;
		}
	},
	computed: {
		askClass: function () {
			return ((this.is_askfor == 1) ? 'register show' : 'register');
		},
		labelStr: function () {
			return JSON.stringify(this.label);
		}
	},
	created: function () {
		/******************* 个人信息载入 *******************/
		var _this = this;
		getData();
		
		/******************* 用户活动载入 *******************/
		// $.ajax({
		// 	url: userActivityUrl,
		// 	type: 'post',
		// 	data: {user_id: userId},
		// 	success: function (data) {
		// 		console.log(data)
				
		// 		_this.activity = data.list;
		// 	}
		// });
	},
	updated: function () {
		$('html body .wrap').height($('html body .wrap .user-detail .pic').height() + $('html body .wrap .user-detail .detail .nav').height() + $('.swiper-slide').eq(0).height());

		// 根据相册图片高宽比确定显示方式
		core.centerImg('html body .wrap .user-detail .detail .swiper-wrapper .swiper-slide:nth-child(2) a span img');
		// var $img = $('html body .wrap .user-detail .detail .swiper-wrapper .swiper-slide:nth-child(2) a span img'),
		// 	srcArr = [];

		// for (var i = 0; i < $img.length; i++) {
		// 	srcArr.push($img.eq(i).attr('src'));
		// }

		// core.preLoadPic({
		// 	files : srcArr,		// 加载的图片存储在数组中
		// 	progress : function(precent, currentImg, index) {		// 每加载完成一张图片回调
		// 		rateClass(index);
		// 	},
		// 	complete : function() {		// 加载完成后回调
		// 		// 具体代码
		// 	}
	 // 	});

		// for (var i = 0; i < $img.length; i++) {
		// 	rateClass(i);
		// }

		// function rateClass(i) {
		// 	var width = $img.eq(i).width(),
		// 		height = $img.eq(i).height(),
		// 		standard = 9.2 * rem,
		// 		rate = core.decimalRound(width / height, 2);
		// 	if (rate > 1) {
		// 		$img.eq(i).removeClass('horizontal vertical square').addClass('horizontal').css({
		// 			margin: '0',
		// 			marginLeft: (((standard * rate - standard) / 2) * -1) + 'px'
		// 		});
		// 	} else if (rate < 1) {
		// 		$img.eq(i).removeClass('horizontal vertical square').addClass('vertical').css({
		// 			margin: '0',
		// 			marginTop: (((standard / rate - standard) / 2) * -1) + 'px'
		// 		});
		// 	} else if (rate == 1) {
		// 		$img.eq(i).removeClass('horizontal vertical square').addClass('square').css('margin', 0);
		// 	}
		// }
	},
	mounted: function () {
		// common.bindBack();
		common.back = function () {
			(isSelf == 1) ? core.href(userUrl) : history.back();
		}

		var $pic = $('html body .wrap .user-detail .pic'),
			$nav = $('html body .wrap .user-detail .detail .nav'),
			_this = this;

		// 点击设置按钮
		$('html body .header-title strong').on('tap', function () {
			var $this = $(this);
			layer.open({
				content: (_this.is_self ? '<a href="' + userHeaderUrl + '" title="">换头像</a>' : '<div class="black-list">' + ((_this.is_black == 1) ? '移出黑名单' : '加入黑名单') + '</div><div class="user-report" href="' + userSetting + '?user_id=' + userId + '&type=2' + '" title="">举报/申诉</div>') + '<span>取消</span>',
				shadeClose: false,
				skin: 'footer',
				className: 'user-setting',
				success: function (ele) {
					var $ele = $(ele);

					if (!_this.is_self) {
						$('body .layui-m-layer .layui-m-layermain .layui-m-layersection .user-setting .layui-m-layercont div').on('tap', function () {
							var $this = $(this);

							$.ajax({
								url: myInfoUrl,
								type: 'post',
								success: function (data) {
									console.log(data);
									if (data.list.is_verify == 1) {
										if ($this.hasClass('black-list')) {
											common.layerConfirm({
												content: ((_this.is_black == 1) ? '移出黑名单后，可以看到彼此的活动邀约和资料，是否确定？' : '用户被拉黑后，将看不到彼此的活动邀约和资料，是否确定？'),
												yes: function (index) {
													if (_this.is_black == 0) {
														$.ajax({
															url: addBlackUrl,
															type: 'post',
															data: {bl_user_id: userId},
															success: function (data) {
																console.log(data)
																core.layerHint(data.message);
																if (data.result == 1) {
																	_this.is_black = 1;
																}
															}
														});
													} else {
														$.ajax({
															url: removeBlackUrl,
															type: 'post',
															data: {bl_user_id: userId},
															success: function (data) {
																console.log(data)
																core.layerHint(data.message);
																if (data.result == 1) {
																	_this.is_black = 0;
																}
															}
														});
													}
												}
											});
										} else if ($this.hasClass('user-report')) {
											core.href($this.attr('href'));
										}
									} else {
										if (data.list.jump_status == 4) {
											core.href(userIdentifyUrl + '?user_id=' + data.list.id);
										} else if (data.list.jump_status == 5) {
											core.href(userHeaderUrl + '?user_id=' + data.list.id);
										} else {
											core.href(userCompleteUrl);
										}
									}
								}
							});
						});
					}

					$('#changeHeader').on('change', function () {
						lrz(document.getElementById('changeHeader').files[0], {
							width: 400
						}).then(function(data) {
							// $.ajax({
							// 	url: userAddPhotoUrl,
							// 	type: 'post',
							// 	data: {
							// 		user_id: userId,
							// 		image: data.base64
							// 	},
							// 	success: function(data) {
							// 		console.log(data)

							// 		core.layerHint(data.message);
							// 		if (data.result == 1) {
							// 			getData();
							// 		}
							// 	}
							// });
						});
					});

					$ele.find('.layui-m-layershade').on('tap', function () {
						layer.close($ele.attr('index'));
					});
					$('body .layui-m-layer .layui-m-layermain .layui-m-layersection .user-setting .layui-m-layercont span').on('tap', function () {
						setTimeout(function () {
							layer.close($ele.attr('index'));
						}, 25);
					});
				},
				end: function () {
					
				}
			});
		});

		/******************* 创建Swiper *******************/
		var detailSwiper = new Swiper ('.detail', {
			direction: 'horizontal',
			loop: false,
			onlyExternal : true,
			onInit: function (swiper) {
				/******************* 点击导航按钮切换tab *******************/
				var $nav = $('html body .wrap .user-detail .detail .nav strong, html body .wrap .user-detail .detail .nav'),
					$body = $('body');

				$body.find('.nav').height($body.find('.nav').height() + 1);
				$body.on('touchstart', '.swiper-pagination-bullet', function (event) {
					event.preventDefault();
				});
				$body.find('.swiper-pagination-bullet').eq(0).addClass('swiper-pagination-bullet-active');

				$body.on('tap', '.swiper-pagination-bullet', function () {
					var $this = $(this),
						thisIndex = $this.index();
					$this.addClass('swiper-pagination-bullet-active').siblings().removeClass('swiper-pagination-bullet-active');
					swiper.slideTo(thisIndex, 600, false);
					$('html body .wrap').height($pic.height() + $nav.height() + $('.swiper-slide').eq(thisIndex).height());
				});
			}
		});

		/******************* 日期选择窗 *******************/
		// 时间选择
		$dateTime = $('html body .wrap .user-detail .detail .swiper-wrapper .swiper-slide:nth-child(1) ul li #date');

		// 关闭弹窗的功能
		$dateTime.datetimePicker({
			cssClass: 'date-time',
			toolbarTemplate: '<header class="bar bar-nav">请选择时间</header>\
			<footer class="picker-footer">\
				<span class="confirm">确定</span>\
			</footer>',
			maxDate: core.dateDetail().ymd2,
			onOpen: function () {
				var $selectCon = $('html body .date-time .picker-items .picker-center-highlight, .picker-item'),
						selectConHeight = core.decimalRound($selectCon.height(), 0) + 'px';
				$selectCon.css({
					height: selectConHeight,
					lineHeight: selectConHeight
				});
				common.pickerBacIn();
				$('html body .date-time .picker-items .picker-items-col:nth-child(4), html body .date-time .picker-items .picker-items-col:nth-child(5), html body .date-time .picker-items .picker-items-col:nth-child(6), html body .date-time .picker-items .picker-items-col:nth-child(7)').css(dn);
				_this.isDateTimeClose = false;
				$('html body .date-time .picker-footer span').on('tap', function () {
					_this.isDateTimeClose = true;
					$dateTime.picker('close');
				});
			},
			onClose: function (picker) {
				common.pickerBacOut();
				if (_this.isDateTimeClose) {
					var age = core.decimalRound((core.dateDetail().getTime - (new Date(picker.value[0], picker.value[1], picker.value[2], picker.value[3], picker.value[4]))) / 1000 / 60 / 60 / 24 / 365, 0);

					if (age >= 18) {
						_this.age = age;
						_this.star = core.constellation(picker.value[1], picker.value[2]);
						
						$.ajax({
							url: userUpdateUrl,
							type: 'post',
							data: {
								user_id: _this.userId,
								age: _this.age,
								star: _this.star
							},
							success: function(data) {
								console.log(data)

								core.layerHint(data.message);
								getData();
							}
						});
					} else {
						core.layerHint('年龄不可小于18岁哦');
					}
				}
			}
		});


		/******************* 城市选择窗 *******************/
		var $city = $('#city');

		// 点击确认按钮
		$('html body').on('tap', '.city-picker .picker-footer .confirm', function () {
			_this.inviteTime = $dateTime.val();
			citySelect = true;
			closeFun();
		});

		function closeFun() {
			var $picker = $('body .picker-columns');
			if ($picker.hasClass('city-picker')) {
				$city.picker('close');
			}
		}

		$city.cityPicker({
			toolbarTemplate: '<header class="bar bar-nav">请选择城市</header>\
			<footer class="picker-footer">\
				<span class="confirm">确定</span>\
			</footer>',
			cssClass: 'city-picker',
			onOpen: function () {
				var $selectCon = $('html body .date-time .picker-items .picker-center-highlight, .picker-item'),
						selectConHeight = core.decimalRound($selectCon.height(), 0) + 'px';
				$selectCon.css({
					height: selectConHeight,
					lineHeight: selectConHeight
				});
				citySelect = false;
				common.pickerBacIn();
			},
			onClose: function (picker) {
				common.pickerBacOut();
				if (citySelect) {
					console.log(picker)
					if (core.listJudge(picker.displayValue[0], ['北京', '上海', '天津', '重庆', '香港', '澳门'])) {
						_this.city = picker.displayValue[0];
					} else {
						_this.city = picker.displayValue[1];
					}
					$.ajax({
						url: userUpdateUrl,
						type: 'post',
						data: {
							user_id: userId,
							city: _this.city
						},
						success: function(data) {
							console.log(data)

							core.layerHint(data.message);
							getData();
						}
					});
				}
			}
		});
	}
});

